MV_CC_SetImageNodeNum

MV_CC_SetImageNodeNum

Set the number of SDK internal image buffer nodes.

API Definition

int MV_CC_SetImageNodeNum(
  void            *handle,
  unsigned int    nNum
);

Parameters

handle

[IN] Device handle, which is returned by MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

nNum

[IN] The number of SDK internal image buffer nodes; its value should be larger than or equal to 1, and the default value is "1".

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

Remarks

  • Call this API to set the number of SDK internal image buffer nodes. The API should be called before calling MV_CC_StartGrabbing for capturing.

  • This API is not supported by CameraLink device.

The following sample code is for reference only.

#include "MvCameraControl.h"

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add system time at output
        char   szInfo[128] = {0};
        SYSTEMTIME sys; 
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
           
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing
    
    //Set number of SDK internal image buffer nodes
    unsigned int nNum = 15;
    nRet = MV_CC_SetImageNodeNum(handle, nNum);
    if (MV_OK != nRet)
    {
        printf("error: SetImageNodeNum fail [%x]\n", nRet);
        return;
    }

    //Register data callback function, get acquired image data in the callback function
    nRet = MV_CC_RegisterImageCallBack(handle, ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    //Start image acquiring
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
         printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop image acquiring
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        OutputString(_T("Operation: Stop Grabbing......failed!"));
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}

MV_CC_SetImageNodeNum

Set the number of SDK internal image buffer nodes.

API Definition

int MV_CC_SetImageNodeNum(
  void            *handle,
  unsigned int    nNum
);

Parameters

handle

[IN] Device handle, which is returned by MV_CC_CreateHandle or MV_CC_CreateHandleWithoutLog.

nNum

[IN] The number of SDK internal image buffer nodes; its value should be larger than or equal to 1, and the default value is "1".

Return Value

Return MV_OK(0) on success, and return Error Code on failure.

Remarks

  • Call this API to set the number of SDK internal image buffer nodes. The API should be called before calling MV_CC_StartGrabbing for capturing.

  • This API is not supported by CameraLink device.

The following sample code is for reference only.

#include "MvCameraControl.h"

void __stdcall ImageCallBack(unsigned char * pData, MV_FRAME_OUT_INFO* pFrameInfo, void* pUser)
{
    if (pFrameInfo)
    {
        // Add system time at output
        char   szInfo[128] = {0};
        SYSTEMTIME sys; 
        GetLocalTime( &sys );
        sprintf_s(szInfo, 128, "[%d-%02d-%02d %02d:%02d:%02d:%04d] : GetOneFrame succeed, width[%d], height[%d]", sys.wYear, sys.wMonth,
            sys.wDay, sys.wHour, sys.wMinute, sys.wSecond, sys.wMilliseconds, pFrameInfo->nWidth, pFrameInfo->nHeight);

        printf("%s\n", szInfo);
    }
}

void main()
{
    int nRet = -1;
    void* m_handle = NULL;

    //Enumerate all devices corresponding to specified transport protocol within subnet
    unsigned int nTLayerType = MV_GIGE_DEVICE | MV_USB_DEVICE;
    MV_CC_DEVICE_INFO_LIST m_stDevList = {0};
    int nRet = MV_CC_EnumDevices(nTLayerType, &m_stDevList);
    if (MV_OK != nRet)
    {
        printf("error: EnumDevices fail [%x]\n", nRet);
        return;
    }

    int i = 0;
    if (m_stDevList.nDeviceNum == 0)
    {
        printf("no camera found!\n");
        return;
    }

    //Select the first found online device and create device handle
    int nDeviceIndex = 0;

    MV_CC_DEVICE_INFO m_stDevInfo = {0};
    memcpy(&m_stDevInfo, m_stDevList.pDeviceInfo[nDeviceIndex], sizeof(MV_CC_DEVICE_INFO));

    nRet = MV_CC_CreateHandle(&m_handle, &m_stDevInfo);

    if (MV_OK != nRet)
    {
        printf("error: CreateHandle fail [%x]\n", nRet);
        return;
    }

    //Connect device
    unsigned int nAccessMode = MV_ACCESS_Exclusive;
    unsigned short nSwitchoverKey = 0;
           
    nRet = MV_CC_OpenDevice(m_handle, nAccessMode, nSwitchoverKey);
    if (MV_OK != nRet)
    {
        printf("error: OpenDevice fail [%x]\n", nRet);
        return;
    }
    //...other processing
    
    //Set number of SDK internal image buffer nodes
    unsigned int nNum = 15;
    nRet = MV_CC_SetImageNodeNum(handle, nNum);
    if (MV_OK != nRet)
    {
        printf("error: SetImageNodeNum fail [%x]\n", nRet);
        return;
    }

    //Register data callback function, get acquired image data in the callback function
    nRet = MV_CC_RegisterImageCallBack(handle, ImageCallBack, NULL);
    if (MV_OK != nRet)
    {
        printf("error: RegisterImageCallBack fail [%x]\n", nRet);
        return;
    }

    //Start image acquiring
    nRet = MV_CC_StartGrabbing(m_handle);
    if (MV_OK != nRet)
    {
         printf("error: StartGrabbing fail [%x]\n", nRet);
        return;
    }

    //...other processing

    //Stop image acquiring
    nRet = MV_CC_StopGrabbing(m_handle);
    if (MV_OK != nRet)
    {
        OutputString(_T("Operation: Stop Grabbing......failed!"));
        return;
    }

    //Shut device and release resource
    nRet = MV_CC_CloseDevice(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: CloseDevice fail [%x]\n", nRet);
        return;
    }

    //Destroy handle and release resource
    nRet = MV_CC_DestroyHandle(m_handle);
    if (MV_OK != nRet)
    {
        printf("error: DestroyHandle fail [%x]\n", nRet);
        return;
    }
}